;(function($){
    var defaults = {
        message:"",// 提示的消息
        type:'success',
        timeout: 3000
    };
    var icon = {
        success: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="-5 -7 24 24" width="24" height="24" class="fill-current text-green-500"><path d="M5.486 9.73a.997.997 0 0 1-.707-.292L.537 5.195A1 1 0 1 1 1.95 3.78l3.535 3.535L11.85.952a1 1 0 0 1 1.415 1.414L6.193 9.438a.997.997 0 0 1-.707.292z"></path></svg>',
        error:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="-6 -6 24 24" width="24" height="24"  class="fill-current text-red-500"><path d="M7.314 5.9l3.535-3.536A1 1 0 1 0 9.435.95L5.899 4.485 2.364.95A1 1 0 1 0 .95 2.364l3.535 3.535L.95 9.435a1 1 0 1 0 1.414 1.414l3.535-3.535 3.536 3.535a1 1 0 1 0 1.414-1.414L7.314 5.899z"></path></svg>'
    };

    $.extend({
        message:function(option){
            var options;
            if (typeof option === 'object') {
                options = $.extend({},defaults,option);
            } else {
                options = $.extend({},defaults,{message:option});
            }

            var div = document.createElement('div');
            div.className = 'max-w-lg w-64 z-50 py-4 px-6 bg-white rounded-lg shadow-md absolute right-4 top-24 flex items-center message top-swiping messages';
            div.innerHTML = icon[options.type] + options.message;
            $('body').append(div);
            setTimeout(function () {
                $(div).addClass('message-remove');
                setTimeout(function () {
                    $(div).remove();
                }, 300);
            }, options.timeout);
        }
    });
})(jQuery);
